package Day013_线程安全.ZuoYe.Test2;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @author zhangyan
 * @date 2020/5/4 18:13
 */
public class Test2 {
    public static void main(String[] args) throws InterruptedException {
        //创建线程池
        ExecutorService es = Executors.newFixedThreadPool(2);
        //创建任务
        MyRunnable mr1 = new MyRunnable("张三");
        MyRunnable mr2 = new MyRunnable("李四");
        //提交并执行任务
        es.submit(mr1);

        es.submit(mr2);
        //结束线程池
        es.shutdown();
    }
}
